package org.example.test_03.Controller;

import org.example.test_03.Domian.Ad;
import org.example.test_03.Domian.ReturnData;
import org.example.test_03.Domian.Student;
import org.example.test_03.Service.AdService;
import org.example.test_03.Service.StudentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
@RequestMapping("/student")
public class StudentController {
    @Resource
    StudentService studentService;


    @GetMapping("/all")
    public ReturnData seletc(String username){
        return  studentService.selects(username);
    }

    /**
     * 根据ID获取学生数据
     * @return
     */
    @GetMapping("/getStuById")
    public ReturnData getStuById(int id){
        //alt+回车
        return  studentService.getStuById(id);
    }
    /**
     * 删除  ，POST 和GET请求的区别  POST一般用在修改数据库内容的时候，get一般用在查询数据
     */
    @PostMapping("delete")
    public ReturnData delete(@RequestBody Student student){
        return studentService.delete(student.getId());
    }

    /**
     * 修改学生数据
     */
    @PostMapping("edit")
    public ReturnData edit(@RequestBody Student student){
        return studentService.edit(student);
    }
}
